package EqualsExercise;

import java.util.Objects;

public class OrderTest {
    public static void main(String[] args) {
        Order order1 = new Order(1001,"AA");
        Order order2 = new Order(1001,"AB");
        Order order3 = new Order(1001,"AB");
        System.out.println(order1.equals(order2));
        System.out.println(order2.equals(order3));


    }
}

class Order{
    private int orderID;
    private String orderName;

    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    public int getOrderID() {
        return orderID;
    }

    public void setOrderID(int orderID) {
        this.orderID = orderID;
    }


    public Order(int orderID,String orderName) {
        this.orderID = orderID;
        this.orderName = orderName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof Order))
            return false;
        Order order = (Order) o;
        return orderID == order.orderID && Objects.equals(orderName, order.orderName);
    }

}
